From: Tim Deegan Date: Thu, 20 Sep 2007 09:54:52 +0000 (+0100) Subject: [HVM] iommu p2m ops: check guest is translated, and maintain m2p consistency X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14937^2~57 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=93e7d8905aa01a036462bff15933b88f3f3da2d9;p=xen.git [HVM] iommu p2m ops: check guest is translated, and maintain m2p consistency Signed-off-by: Tim Deegan --- diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 5569cbe632..a241d7cbb3 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -873,6 +873,18 @@ int set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) { int rc = 0; + p2m_type_t ot; + mfn_t omfn; + + if ( !paging_mode_translate(d) ) + return 0; + + omfn = gfn_to_mfn(d, gfn, &ot); + if ( p2m_is_ram(ot) ) + { + ASSERT(mfn_valid(omfn)); + set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY); + } rc = set_p2m_entry(d, gfn, mfn, p2m_mmio_direct); if ( 0 == rc ) @@ -886,8 +898,11 @@ int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn) { int rc = 0; - unsigned long mfn; + + if ( !paging_mode_translate(d) ) + return 0; + mfn = gmfn_to_mfn(d, gfn); if ( INVALID_MFN == mfn ) {